package org.devcp.tp.common.listener;

import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.devcp.tp.common.event.SysEvent;
import org.devcp.tp.common.event.SysEventRegister;
import org.devcp.tp.common.event.cache.TpartnerEhcacheManager;
import org.devcp.tp.common.event.listner.SysEventListener;
import org.devcp.tp.common.event.util.SysEventUtil;
import org.devcp.tp.common.websocket.WebsocketSessionUtil;
import org.devcp.tp.common.websocket.model.WebsocketSessionWrapper;
import org.jweb.core.util.ResourceUtil;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.socket.TextMessage;

import com.alibaba.fastjson.JSONObject;

/**
 * 系统事件注册监听器，当定义了新的系统事件，需要在该监听器中配置，该监听器是servlet容器监听器
 * @author Administrator
 *
 */
public class SysEventRegistListener implements ServletContextListener,Serializable {

	private static ApplicationContext ctx = null;
	
	@Override
	public void contextInitialized(ServletContextEvent sce) {
		
		 ctx = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
		 
		 
//		 Map<String,SysEventRegister> registerMap = SysEventUtil.registerMap;
		 
		 //注册房间讲话监听器
//		 if(!registerMap.containsKey("1")){//通过id防止缓存服务器中存放多个相同的注册器，当频繁开启应用服务器，而没有重启缓存服务器就会导致存放多个注册器
//			 
//		 }
		 
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub

	}
	
	public static ApplicationContext getCtx() {
		return ctx;
	}
	
	

}